﻿using GraphProcessor;
using IQIGame.Onigao.Logic;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay.Editors
{
    [System.Serializable, NodeMenuItem(LevelEditorConst.Execution + "/" + LevelEditorConst.ResetEntity, typeof(LevelServiceGraph))]
    public class LevelServiceExecutionNode_ResetEntity : LevelServiceExecutionNode
    {
        protected override ServiceExecutionType mServiceType => ServiceExecutionType.ResetEntity;

        public override string name => LevelEditorConst.ResetEntity;
        [Output("目标", false)] public EditorLevelServiceDynamicListSetter tagOrMcid;

        protected override LevelServiceCustomConfig CreateConfig()
        {
            var rConfig = new LevelServiceExecutionCustom_ResetEntity()
            {
                // tagOrMcid = this.tagOrMcid,,
                tagOrMcid = LevelServiceDynamicListSelectNode.DefaultParam
            };
            this.tagOrMcid = new EditorLevelServiceDynamicListSetter(x => rConfig.tagOrMcid = x);
            return rConfig;
        }
        
        protected override void OnSync(EditorLevelServiceExecutionConfig newConfig, LevelServiceExecutionNode tempNode)
        {
            if (newConfig.customConfig is LevelServiceExecutionCustom_ResetEntity rConfig)
            {
                this.SyncTarget(rConfig.tagOrMcid);
            }
        }
    }
}